const { handle } = require("express/lib/application")

function getJSON(url){
    let promise = new Promise(function(resolve,reject){
        let xhr = new XMLHttpRequest();
        xhr.open('GET',url,true);
        xhr.onreadystatechange = function(){
            if(xhr.status !== 4)return;
            else if(xhr.status === 200){
                resolve(this.response)
            }
            else{
                reject(new Error(this.statusText))
            }
        }
        xhr.onerror = function(){
            reject(new Error(this.statusText))
        }
    })
    return promise;
}